/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;

/**
 *
 * @author Human Booster
 */
@Entity
@Table(name = "customerorder")
@NamedQueries({
    @NamedQuery(name = "Customerorder.findAll", query = "SELECT c FROM Customerorder c"),
    @NamedQuery(name = "Customerorder.findById", query = "SELECT c FROM Customerorder c WHERE c.customerorderPK.id = :id"),
    @NamedQuery(name = "Customerorder.findByOrderDate", query = "SELECT c FROM Customerorder c WHERE c.orderDate = :orderDate"),
    @NamedQuery(name = "Customerorder.findByCustomerid", query = "SELECT c FROM Customerorder c WHERE c.customerorderPK.customerid = :customerid")})
public class Customerorder implements Serializable {
    @Basic(optional = false)
    @Column(name = "orderDate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date orderDate;
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CustomerorderPK customerorderPK;
    @JoinColumn(name = "Customer_id", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Customer customer;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerorder")
    private Collection<Licencecustomer> licencecustomerCollection;

    public Customerorder() {
    }

    public Customerorder(CustomerorderPK customerorderPK) {
        this.customerorderPK = customerorderPK;
    }

    public Customerorder(CustomerorderPK customerorderPK, Date orderDate) {
        this.customerorderPK = customerorderPK;
        this.orderDate = orderDate;
    }

    public Customerorder(int id, int customerid) {
        this.customerorderPK = new CustomerorderPK(id, customerid);
    }

    public CustomerorderPK getCustomerorderPK() {
        return customerorderPK;
    }

    public void setCustomerorderPK(CustomerorderPK customerorderPK) {
        this.customerorderPK = customerorderPK;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Collection<Licencecustomer> getLicencecustomerCollection() {
        return licencecustomerCollection;
    }

    public void setLicencecustomerCollection(Collection<Licencecustomer> licencecustomerCollection) {
        this.licencecustomerCollection = licencecustomerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (customerorderPK != null ? customerorderPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Customerorder)) {
            return false;
        }
        Customerorder other = (Customerorder) object;
        if ((this.customerorderPK == null && other.customerorderPK != null) || (this.customerorderPK != null && !this.customerorderPK.equals(other.customerorderPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Customerorder[ customerorderPK=" + customerorderPK + " ]";
    }

    public Date getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(Date orderDate) {
        this.orderDate = orderDate;
    }
    
}
